package com.itheima.reggie.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Description: test
 * @Create by: 陌离
 * @Date: 2021/9/23 11:49
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 全局异常处理
     * @param e
     * @return
     */
    @ExceptionHandler({Exception.class})
    public R handlerException(Exception e){
        e.printStackTrace();
        return R.error("服务器异常,请稍后重试");
    }

    /**
     * 订单删除异常处理方法
     * @param ex
     * @return
     */
    @ExceptionHandler(CustomException.class)
    public R<String> exceptionHandler(CustomException ex){
        return R.error(ex.getMessage());
    }
}
